package com.zhaoshixin.rabbit.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

//@Component
public class DeadConsumer {

    @RabbitListener(queues = "deadLetterQueue1")
    public void receiveBizMsg1(Message message, Channel channel) throws IOException {
        System.out.println("收到<<<死信消>>>消息1：" + new String(message.getBody()));
        //消息确认
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }


    @RabbitListener(queues = "deadLetterQueue2")
    public void receiveBizMsg2(Message message, Channel channel) throws IOException {
        System.out.println("收到<<<死信消>>>息2：" + new String(message.getBody()));
        //消息确认
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}
